#Author: Tanyong
# *-* coding:utf8 *-*
# @time       : 2018/7/17 21:56
# @Author     : Tanyong
# @Site       : 
# @File       : config.py
# @Software   : PyCharm
import logging
from redis import StrictRedis


class Config():
    DEBUG = True
    SECRET_KEY = "LI16bzP85eAeSxcDFTEiG59TSPruIccUjOu5WEYwdkZswjbJFNZajM69y3G88QG1"

    # 数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:tanyong123@127.0.0.1:3306/miniweb_flask"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis配置
    REDIS_HOST = "192.168.56.132"
    REDIS_PORT = 6379

    # Session配置
    # 指定session存储位置 redis
    SESSION_TYPE = "redis"
    # 指定redis 数据库地址和端口
    SESSION_REDIS = StrictRedis(REDIS_HOST, REDIS_PORT)
    # 用户签名开启, 加密
    SESSION_USE_SIGNER = True
    # 设置 session 为非永久有效
    SESSION_PERMANENT = False
    # 设置 session的有效时间 2天
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    # 日志的等级配置
    LOG_LEVEL = logging.DEBUG

class DevelopementConfig(Config):
    """开发模式下的配置"""
    DEBUG = True


class ProductionConfig(Config):
    """生产模式下的配置"""
    pass
    LOG_LEVEL = logging.WARNING


class TestingConfig(Config):
    """单元测试的配置"""
    DEBUG = True
    TESTING = True

config = {
    "development": DevelopementConfig,
    "production": ProductionConfig,
    "testing": TestingConfig
}